/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var total = 0;
var Map = {};

function getTotal(element)
{ 
    total = element.checked ? (total+parseFloat(element.value)) : (total-parseFloat(element.value));
    if(element.checked) {
        addToMap(element.id, element.value);
    }
    else {
        removeFromMap(element.id)
    }


    document.getElementById("subTotal").innerHTML = total.toFixed(2);
}

function addToMap(id, value) {
    if(!Map.hasOwnProperty(id)) {
        Map[id] = value;
    }
}

function removeFromMap(id) {
     if(Map.hasOwnProperty(id)) {
       delete Map[id]; 
     }
}